
import React from "react"
const TestComponent = () => {
  let rowlist = [
    {
      id: 1001,
      name: 'react'
    },
    {
      id: 1002,
      name: 'vue'
    }
  ]
  const [list, setList] = React.useState(rowlist);

  const onDel = (e, id) => {
    setList(list.filter(item => item.id !== id));
  }
  return (
    <ul>
      {list.map(item => (
        <li key={item.id}>
          {item.name}
          <button onClick={(e) => onDel(e, item.id)}>x</button>
        </li>
      ))
      }
    </ul >
  )
}

function App() {
  return (
    <div>
      <TestComponent />
    </div>
  )
}


export default App